package com.ruoyi.web.controller.glue;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.GlueReport;
import com.ruoyi.system.service.IGlueReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * 报告上传信息
 *
 * @author ruoyi
 * @date 2025-03-31
 */

@Validated
@RestController
@RequestMapping("/system/report")
public class GlueReportController extends BaseController
{
    @Autowired
    private IGlueReportService glueReportService;

    /**
     * 查询报告上传信息列表
     * @return {@link GlueReport}
     */
    //@PreAuthorize("@ss.hasPermi('system:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(GlueReport glueReport)
    {
        startPage();
        List<GlueReport> list = glueReportService.selectGlueReportList(glueReport);
        return getDataTable(list);
    }

    /**
     * 导出报告上传信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:report:export')")
    @Log(title = "报告上传信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GlueReport glueReport)
    {
        List<GlueReport> list = glueReportService.selectGlueReportList(glueReport);
        ExcelUtil<GlueReport> util = new ExcelUtil<GlueReport>(GlueReport.class);
        util.exportExcel(response, list, "报告上传信息数据");
    }

    /**
     * 获取报告上传信息详细信息
     * @return {@link GlueReport}
     */
    //@PreAuthorize("@ss.hasPermi('system:report:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(glueReportService.selectGlueReportById(id));
    }

    /**
     * 新增报告上传信息
     */
    //@PreAuthorize("@ss.hasPermi('system:report:add')")
    @Log(title = "报告上传信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid  @RequestBody GlueReport glueReport)
    {
        return toAjax(glueReportService.insertGlueReport(glueReport));
    }

    /**
     * 修改报告上传信息
     */
    //@PreAuthorize("@ss.hasPermi('system:report:edit')")
    @Log(title = "报告上传信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody GlueReport glueReport)
    {
        return toAjax(glueReportService.updateGlueReport(glueReport));
    }

    /**
     * 删除报告上传信息
     */
    //@PreAuthorize("@ss.hasPermi('system:report:remove')")
    @Log(title = "报告上传信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(glueReportService.deleteGlueReportByIds(ids));
    }
}
